<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div><h1>helloworld</h1></div>
    <input type="button" value="点击" onclick="test()">

    <script>
        /* 
            innerText:操作标签中的文本内容
            innerHTML:操作标签中的HTML内容(包含标签和文本)
        */
        function test() {
            var div = document.getElementsByTagName("div")[0];
            //console.log(div.innerText); //helloworld
            //console.log(div.innerHTML); //<h1>helloworld</h1>
            //div.innerText = "你好";
            //div.innerHTML = "你好";
            //div.innerText = "<i>你好</i>";
            div.innerHTML = "<i>你好</i>";
        }
    </script>
</body>
</html>